import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class MyLinkedList{
    static class ListNode{
        ListNode next;
        int val;
        public ListNode(int val){
            this.val = val;
        }
    }
    public ListNode head;
    public void add(int val){
        ListNode newnode = new ListNode(val);
        if(this.head==null){
            this.head = newnode;
            return ;
        }
        ListNode cur = this.head;
        while(cur.next!=null){
            cur = cur.next;
        }
        cur.next = newnode;
    }    public  ListNode removeNthFromEnd(ListNode head, int n) {
        if(n<1||head==null){
            return null;
        }
        ListNode cur = head;
        int k = n;
        while(cur!=null){
            cur = cur.next;
            k--;
        }
        if(k==0){
            return head.next;
        }
        if(k<0){
            cur = head;
            while(k!=-1){
                k++;
                cur = cur.next;
            }
            cur.next = cur.next.next;
        }
        return head;

    }

    public void PrintLinkedList(){
        ListNode cur = this.head;
        while(cur!=null){
            System.out.print(cur.val+" ");
            cur = cur.next;
        }
    }

    public void createNodeList(String[] str){
        this.head = str[0];
    }
}


public class Main {
    public static void main (String[] args) throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = input.readLine().split(" ");
        String[] s2 = input.readLine().split(" ");
        MyLinkedList myLinkedList = new MyLinkedList();
        int lastindex = Integer.parseInt(s1[1]);
        myLinkedList.head = MyLinkedList
        myLinkedList.removeNthFromEnd(myLinkedList.head,lastindex);
        myLinkedList.PrintLinkedList();
    }
}
